]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
appFavorites: Hide favourites which are blacklisted by parental controls
authorPhilip Withnall <withnall@endlessm.com>
Tue, 31 Mar 2020 09:33:18 +0000 (10:33 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Tue, 7 Apr 2020 15:47:33 +0000 (17:47 +0200)
If a favourite is set for an app which is blocked by parental controls,
that favourite should be hidden.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/465

js/ui/appFavorites.js

index 653f0cfba1e3debe8aa175d2a8f1ce04cae9902f..c65040d8a2af1b2c7d53b2f4aca05d2507a1e219 100644 (file)
@@ -2,6 +2,7 @@
 /* exported getAppFavorites */
 
 const Shell = imports.gi.Shell;
+const ParentalControlsManager = imports.misc.parentalControlsManager;
 const Signals = imports.signals;
 
 const Main = imports.ui.main;
@@ -64,6 +65,13 @@ const RENAMED_DESKTOP_IDS = {
 
 class AppFavorites {
     constructor() {
+        // Filter the apps through the user’s parental controls.
+        this._parentalControlsManager = ParentalControlsManager.getDefault();
+        this._parentalControlsManager.connect('app-filter-changed', () => {
+            this.reload();
+            this.emit('changed');
+        });
+
         this.FAVORITE_APPS_KEY = 'favorite-apps';
         this._favorites = {};
         global.settings.connect('changed::%s'.format(this.FAVORITE_APPS_KEY), this._onFavsChanged.bind(this));
@@ -95,7 +103,7 @@ class AppFavorites {
             global.settings.set_strv(this.FAVORITE_APPS_KEY, ids);
 
         let apps = ids.map(id => appSys.lookup_app(id))
-                      .filter(app => app != null);
+                      .filter(app => app !== null && this._parentalControlsManager.shouldShowApp(app.app_info));
         this._favorites = {};
         for (let i = 0; i < apps.length; i++) {
             let app = apps[i];
@@ -134,6 +142,9 @@ class AppFavorites {
         if (!app)
             return false;
 
+        if (!this._parentalControlsManager.shouldShowApp(app.app_info))
+            return false;
+
         let ids = this._getIds();
         if (pos == -1)
             ids.push(appId);